package com.neusoft.demo10;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

public class MapDemo {
    public static void main(String[] args) {
        //创建下个Map集合
        Map<String,String> maps = new HashMap<>();
        //向Map集合中添加一个元素
        maps.put("1","gibson");
        maps.put("2","fender");
        //从Map集合中获取元素，根据key来获取
        String name = maps.get("1");
        System.out.println(name);
        System.out.println("111111111111111111111111111111111111111");
        //如何遍历Map集合
        Set<Map.Entry<String,String>> entrySet = maps.entrySet();
        Iterator<Map.Entry<String,String>> it = entrySet.iterator();
        while (it.hasNext()) {
            Map.Entry<String,String> entry = it.next();
            String key = entry.getKey();
            String value = entry.getValue();
            System.out.println(key + ":" + value);
        }



    }
}
